// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#ifndef MGCTRIMESH_H
#define MGCTRIMESH_H

#include "MgcGeometry.h"


class MgcTriMesh : public MgcGeometry
{
    MgcDeclareRTTI;
    MgcDeclareStream;

public:
    // Construction and destruction.  MgcTriMesh accepts responsibility for
    // deleting the input arrays.
    MgcTriMesh (unsigned int uiVertexQuantity, MgcVector3* akVertex,
        MgcVector3* akNormal, MgcColor* akColor, MgcVector2* akTexture,
        unsigned int uiTriangleQuantity, unsigned int* auiConnect);

    virtual ~MgcTriMesh ();

    void Reconstruct (unsigned int uiVertexQuantity,
        unsigned int uiTriangleQuantity);

    // The reconstruction allows you to change only individual arrays.  You
    // do this by passing in the current array pointers for any arrays you
    // want to preserve.
    void Reconstruct (unsigned int uiVertexQuantity, MgcVector3* akVertex,
        MgcVector3* akNormal, MgcColor* akColor, MgcVector2* akTexture,
        unsigned int uiTriangleQuantity, unsigned int* auiConnect);

    // connectivity access
    unsigned int* Connectivity ();
    const unsigned int* Connectivity () const;

    // triangle access
    unsigned int GetTriangleQuantity () const;
    void GetTriangle (unsigned int uiT, unsigned int& ruiV0,
        unsigned int& ruiV1, unsigned int& ruiV2) const;
    void GetTriangle (unsigned int uiT, MgcVector3& rkV0, MgcVector3& rkV1,
        MgcVector3& rkV2) const;

    // updates
    virtual void UpdateModelNormals ();

protected:
    MgcTriMesh ();

    // drawing
    friend class MgcBezierMesh;
    virtual void Draw (MgcRenderer& rkRenderer);

    // triangles
    unsigned int m_uiTriangleQuantity;
    unsigned int* m_auiConnect;
};

MgcSmartPointer(MgcTriMesh);
MgcRegisterStream(MgcTriMesh);
#include "MgcTriMesh.inl"

#endif
